home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_56 / sbosc.asm < prev    next >
Assembly Source File  |  1995-01-01  |  4KB  |  77 lines

  1. ;==============================================================================
  2. ; Oscillogram for SoundBlaster v1.10
  3. ;   Craig Jackson & André Baresel
  4. ;------------------------------------------------------------------------------
  5. ; Requirements: 8086, DOS 1.0, VGA/MCGA, SoundBlaster (see BASEADDR)
  6. ; Supports    : Microphone, Line, CD
  7. ; Resolutions : 8-bit
  8. ;------------------------------------------------------------------------------
  9.  
  10.     .MODEL tiny
  11.     .8086
  12.  
  13.     BASEADDR    EQU 0220h               ;SoundBlaster base address
  14.     VIDEOCOLS   EQU 320                 ;Video columns
  15.     VIDEOROWS   EQU 200                 ;Video rows
  16.     SAMPLERANGE EQU 128                 ;Range for scaled samplevalues
  17.  
  18.     .CODE
  19.     .STARTUP
  20.  
  21.     ; Initialize graphics
  22.     mov     ax,00013h                   ;Set video mode (320x200x256)
  23.     int     010h                        ;   Interrupt: Video
  24.     mov     ax,0A000h                   ;AX = Video segment
  25.     mov     es,ax                       ;ES = Video segment
  26.  
  27. loopMain:
  28.     ; Clear screen
  29.     mov     di,(VIDEOROWS-SAMPLERANGE)/2*VIDEOCOLS
  30.                                            ;DI = Offset for first column top
  31.     mov     cx,(VIDEOCOLS * SAMPLERANGE)/2 ;CX = Count of words in active area
  32.     mov     ax,00101h                      ;AX = C:C
  33.     rep     stosw                          ;Clear screen
  34.  
  35.     ; Draw oscillogram
  36.     mov     cx,VIDEOCOLS                ;CX = Video columns
  37.     mov     di,(VIDEOROWS-SAMPLERANGE)/2*VIDEOCOLS
  38.                                         ;DI = Offset for first column top
  39. loopRefresh:
  40.     mov     dx,BASEADDR+00Ch            ;DX = DSP Write Data or Command
  41.     mov     al,020h                     ;AL = Direct ADC
  42.     out     dx,al                       ;   Output: DSP Write Data or Command
  43.  
  44.     add     dx,002h                     ;DX = DSP Data Available Status
  45. L0: in      al,dx                       ;
  46.     or      al,al                       ;Check for available sample
  47.     jns     L0                          ;   Jump: Continue available sample check
  48.  
  49.     sub     dx,004h                     ;DX = DSP Read Data
  50.     in      al,dx                       ;AL = ADC Data
  51.  
  52.     push    di                          ;Preserve DI
  53.     mov     dl,VIDEOCOLS/2              ;DL = Video columns / scalar
  54.     and     al,0FEh                     ;AL = ADC Data forced scalar aligned
  55.     mul     dl                          ;AX = Video row offset for sample
  56.     add     di,ax                       ;DI = Video offset to pixel
  57.     mov     ax,00107h                   ;AH = Check for character function
  58.                                         ;AL = Color for oscillogram
  59.     stosb                               ;Store sample
  60.     pop     di                          ;Restore DI
  61.  
  62.     inc     di                          ;DI = Offset for next video column
  63.     int     016h                        ;   Interrupt: Keyboard
  64.     loopz   loopRefresh                 ;   Loop: Continue sampling loop, until keypress
  65.     jz      loopMain                    ;   Jump: Refresh screen, until keypress
  66.  
  67.     ; Terminate program
  68.     xor     ah,ah                       ;Read character, flush keypress
  69.     int     016h                        ;   Interrupt: Keyboard
  70.  
  71.     mov     ax,00003h                   ;Set video mode (80x25x16)
  72.     int     010h                        ;   Interrupt: Video
  73.  
  74.     ret                                 ;Terminate program (old style)
  75.  
  76.     END
  77.